package com.shoulder.log.utils;

import com.shoulder.core.utils.IdUtils;
import org.slf4j.MDC;

public class LogTraceUtils {
    public static final String TRACE_ID = "traceId";

    /**
     * 获取日志追踪id格式
     */
    public static String get() {
        return new IdUtils(1, 1).nextId() + "";
    }

    /**
     * 插入traceId
     */
    public static void set() {
        MDC.put(TRACE_ID, get());
    }

    /**
     * 移除traceId
     */
    public static void clear() {
        MDC.remove(TRACE_ID);
    }
}
